package com.baozou.app.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.ImageView;

import com.baozou.R;
import com.baozou.framework.base.BaseActivity;

public class GestureDetectorDemoActivity extends BaseActivity {
	private final static String D = "GestureDetectorDemoActivity";
	ImageView iv;
	GestureDetector mGestureDetector;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.gesture_detector_demo);
		
		iv = (ImageView)findViewById(R.id.gesture_image);
		mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {
			
			@Override
			public boolean onSingleTapUp(MotionEvent arg0) {
				Log.d(D, "onSingleTapUp");
				return false;
			}
			
			@Override
			public void onShowPress(MotionEvent arg0) {
				Log.d(D, "onShowPress");
				
			}
			
			@Override
			public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
					float arg3) {
				Log.d(D, "onScroll");
				return false;
			}
			
			@Override
			public void onLongPress(MotionEvent arg0) {
				Log.d(D, "onLongPress");
				
			}
			
			@Override
			public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2,
					float arg3) {
				Log.d(D, "onFling");
				return false;
			}
			
			@Override
			public boolean onDown(MotionEvent arg0) {
				Log.d(D, "onDown");
				return false;
			}
		});
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		boolean b = mGestureDetector.onTouchEvent(event);
		boolean bb = super.onTouchEvent(event);
		//Log.d(D, "mGestureDetector.onTouchEvent(event):" + b + ",super.onTouchEvent(event):" + bb);
		return bb;
	}
}
